<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/user-page.css" />
<?php
$conn = mysql_connect("localhost", "root", "123456") or die("Ket noi den MySQL that bai");
mysql_select_db("mp3", $conn);
mysql_query("SET NAMES UTF8", $conn);
?>
<title>lam</title>
</head>
<?php include_once ('master_menu.php'); ?>
<div class="page">
      <?php
$user = $_SESSION["login"];
$sql = "select * from user where username= '" . $user."'";
$q = mysql_query($sql);
while ($row = mysql_fetch_array($q)) 
{
    $id = $row["id_user"];
    $pass = $row["pass"];
    $email = $row["email"];
    $fullname = $row["fullname"];
    $pic = $row["pic"];
    $dc = $row["diachi"];
    $ngaysinh = $row["ngaysinh"];
    $pic = $row["pic"];
?>
<div class="left-user">
  <div class="left-user-small">
    <div class="user-info">
      <div class="avartar"><img src="images/<?= $pic ?>" style="width:130px; height:130px;" /></div>
      <p><?= $user ?></p>
      <ul>
        <li><strong>Playlist:</strong>0</li>
        <li><strong>Lượt view:</strong>999</li>
        <li><strong>Lượt nghe playlist:</strong>1000</li>
      </ul>
    </div>
  </div>
  <div class="right-user-small">
    <div class="blk-user">
      <div class="title-user">
        <p><a>Quản lý tài khoản</a></p>
      </div>
    </div>
    <div class="info-u">
    <form action="" method="post">
      <div class="row-form">
        <strong>Tên tài khoản:</strong> <span><?= $user ?></a></span> <br class="clr"/>
      </div>
      <div class="row-form"> <strong>Mật khẩu:</strong> 
        <input type="password" value="<?= $pass ?>" class="input" id="txtpass"/>
        <span><a href="javascript:;" id="btnChangePassword">Đổi mật khẩu</a></span> <br class="clr">
      </div>
      <div class="row-form"> <strong>Email: </strong> <span><?= $email ?></span> <br class="clr"/>
      </div>
      <div class="row-form"> <strong>Họ và tên:</strong> <span>
        <input type="text" value="<?= $fullname ?>" class="input" id="txtFullname" name="txtFullname"/>
        </span> <br class="clr"/>
      </div>
      <div class="row-form"> <strong>Ngày sinh: </strong> 
      <span>  <input type="date" value="<?= $ngaysinh ?>" class="input" id="txtBrithday" name="txtBrithday"/>
      </span> <br class="clr"/>
       </div>
      <div class="row-form"> <strong>Địa chỉ:</strong> <span>
        <input type="text" value="<?= $dc ?>" class="input" id="txtAddr" name="txtAddr"/>
        </span> <br class="clr"/>
      </div>
      <input type="submit" value="Cật Nhật" name="update"/>
      </form>
      <?php
	      if (isset($_POST["update"]))
            {
                $str = "call updateuser
                ('" .$id."','".$_POST['txtFullname']."','".$_POST['txtBrithday']."','".$_POST['txtAddr']."','".$pic."')";
                echo $str;
                $r = mysql_query($str);
            }
	  ?>
    </div>
    <div class="right-user-small">
      <div class="blk-user">
        <div class="title-user">
          <p><a>Playlist Của Bạn</a></p>
        </div>
      </div>
      <div>
     
       <form action="" method="post">
       <div>
       <a class="apl" href="#" onclick="javascript:document.getElementById('dialog').style.display='block';">Tạo PlayList Mới</a>							</div>
       <div id="dialog" style="display: none;">
        	<span>Tên Playlist</span>
            <input  class="txt" type="text" name="tenpl" value=""/>
            <input class="txt" type="submit" value="Add" name="add"/>
        </div>
        <?php
        $sql = "select * from playlist where id_user= " . $id;
        $q = mysql_query($sql);
        while ($row = mysql_fetch_array($q)) 
        {
             $id_playlist = $row["id_playlist"];

                $ten = $row["tenplaylist"];
                $view=$row["view"];
                $pic=$row["pic"];
            ?>
            <div>
            <div class="pic_album4">
            <a href="chitietpl.php?id=<?=$id?>&id_pl=<?=$id_playlist?>">
            <img src="images/ca79cd05ebbc2de2536374d3a710df85_1356577120.jpg" width="100px" height="100px" /></a>
        	<div class="metaalbum"> <a  href="chitietpl.php?id=<?=$id?>" id="a1"><?=$ten?></a>  <br />

      		</div>
      </div>
      </div>
            <?php } ?>
       </form>
        

<?php

    }  
        if (isset($_POST["tenpl"])) 
        {
            $tenplaylist = $_POST["tenpl"];
            $str = "call insertplaylist_user('" . $tenplaylist . "'," . $id . ")";
            $r=mysql_query($str);
            //$result=mysql_fetch_row($r);//lấy id của playlist mới add vào
        }
       
       ?>
      
           
            
    
      
      </div>
    </div>
  </div>
</div>
<?php 


mysql_close($conn); 
?>

<?php include_once ('master_footer.php'); ?>
